package redis.datatype.impl;

import java.util.List;

import redis.Constant;
import redis.clients.jedis.ShardedJedis;
import redis.datatype.IList;


public class IListImpl implements IList {

	public List getList(ShardedJedis jedis, String key) {
		return jedis.lrange(key, 0, -1);
	}

	public void rAdd(ShardedJedis jedis, String key, String value, int maxLength) {
		if (jedis.llen(key) >= maxLength) {
			jedis.rpop(key);
		}
		jedis.lpush(key, value);
	}

	public void rAdd(ShardedJedis jedis, String key, String value) {
		if (jedis.llen(key) >= Constant.LIST_MAXSIZE) {
			jedis.rpop(key);
		}
		jedis.lpush(key, value);

	}

}
